<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎登陆</title>
<%@ include file="/common/meta.jsp"%>
<script type="text/javascript">
	$(function() {
		/////////////////////////////////////ecTable分页移动到下面///////////////////////////////////////////
		 /* var t1 = $(".eXtremeTable").children("table").not($("#ec_table")).clone();
		$(".eXtremeTable").children("table").not($("#ec_table")).remove();
		$("#ec_table").after(t1); */ 
/////////////////////////////////////点击全选///////////////////////////////////////////
		$("#allItems")
				.click(
						function() {
							var b = this.checked;
							$("input:checkbox").each(function(i) {
								if (!b)
									this.checked = false;
								else
									this.checked = true;
							});
							window.parent.document.getElementById("checkedIds").value = checked();
						});


		//////////////////////////////////删除///////////////////////////////////////////
		$("#deleteIds").click(function() {
			var fields = document.getElementsByName("checkedIds");
			var flags = false;
			for (var i = 0; i < fields.length; i++) {
				if (fields[i].checked) {
					flags = true;
					break;
				}
			}
			if (flags != true) {
				alert("请至少选择一条个用户!");
				return false;
			}
			document.forms[0].target = "listIframe";
			document.forms[0].action = "${ctx}/sys/user/delete.action";
			document.forms[0].submit();
		});
		
	});

	//修改
	function modify(id, name, pass) {
		parent.document.getElementById("save").value="修改";
		parent.document.getElementById("id").value = id;
		parent.document.getElementById("name").value = name;
		parent.document.getElementById("pass").value = pass;
		parent.document.getElementById("pass").disabled = false;
		parent.document.getElementById("addPass").type = "hidden";
	}
	//删除
	function deleteById(id) {
		if (confirm("您确认当前操作吗？确定后将不能修改。")) {
			document.forms[0].target = "listIframe";
			document.forms[0].action = "${ctx}/sys/user/delete.action?checkedIds="
					+ id;
			document.forms[0].submit();
		}
	}
</script>
</head>
<body>
	
		<ec:table items="userList" var="user"
			action="${ctx}/sys/user/list.action"
			imagePath="${pageContext.request.contextPath}/images/ectable/*.gif">
			<ec:exportXls fileName="userList.xls" tooltip="导出 Excel" />
			<ec:row highlightRow="true">
				<ec:column filterable="false" property="checkbox"
					title='<input type="checkbox" name="allItems" id="allItems" value=""/>'
					sortable="false" viewsAllowed="html" style="width: 4%;">
					<input type="checkbox" name="checkedIds" class="itemlist"
						value="${user.id}" style="border: 0px" />
				</ec:column>
				<ec:column property="name" title="用户名" width="18%" alias="name" />
				<ec:column property="pass" title="密&nbsp;码" width="12%" alias="pass" />

				<ec:column filterable="false" property="edit" title="操作"
					sortable="false" viewsAllowed="html" style="width: 10%">
					<a id="modify" style="cursor: hand;"
						onclick="modify('${user.id}','${user.name}','${user.pass}');">修改</a>
					<a style="cursor: hand;" id="delete"
						onclick="deleteById('${user.id}')">删除</a>
				</ec:column>
			</ec:row>
		</ec:table>
		<form method="post" id="userForm"
		action="${ctx}/sys/user/delete.action" style="margin-bottom: 0px;">
		<input type="button"class="button" value="删除所选" id="deleteIds">
	</form>
</body>
</html>